﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace PowerPatcher
{
    public partial class Uninstaller : Form
    {
        public Uninstaller()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string pt = Path.GetTempFileName();
            string p = Path.ChangeExtension(pt, ".exe");
            File.Move(pt, p);
            using (Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("PowerPatcher.Uninstaller.exe"))
            {
                byte[] b = new byte[s.Length];
                s.Read(b, 0, (int)s.Length);
                File.WriteAllBytes(p, b);
            }

            System.Diagnostics.Process.Start(p, string.Format("\"{0}\" {1} {2}", Environment.CurrentDirectory, radioButton2.Checked, System.Diagnostics.Process.GetCurrentProcess().Id));

            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void Uninstaller_Load(object sender, EventArgs e)
        {
            
        }
    }
}
